<template>
  <div class="app-container">
    <!-- 添加或修改利息分摊对话框 -->
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="开始日期" prop="startDate">
          <el-date-picker  clearable :style="{width: '300px'}"
            v-model="form.startDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束日期" prop="endDate">
          <el-date-picker  clearable :style="{width: '300px'}"
            v-model="form.endDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="金额" prop="money">
          <el-input v-model="form.money" placeholder="请输入金额"   clearable :style="{width: '300px'}"/>
        </el-form-item>
        <el-form-item label="年利率" prop="paramVal">
          <el-input v-model="form.paramVal" placeholder="请输入年利率"   clearable :style="{width: '300px'}"/>
        </el-form-item>
         </el-form>
      <div slot="footer" class="dialog-footer" label-width="800px">
        <el-button type="primary" @click="submitForm">计算利息</el-button>
      </div>

  </div>
</template>

<script>
import { getRateYear ,getInterestTool} from "@/api/ibatis/interestTool";

export default {
  name: "InterestTool",
  dicts: ['HOUSE004'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        rateDate: null,
        costDate: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 取消按钮
    cancel() {
      this.reset();
    },
    getList() {
      this.loading = true;
      getRateYear().then(response => {
        this.form = response.data;
        this.areaSelect();
      });
    },
    // 表单重置
    reset() {
      this.form = {
        rateId: null,
        shouldMoney: null,
        rateMoney: null,
        subMoney: null,
        rateDate: null,
        costDate: null,
        remark: null
      };
      this.resetForm("form");
    },

    /** 提交按钮 */
    submitForm() {
      getInterestTool(this.form).then(response => {
        this.$modal.msgSuccess(response.data.interestMoney);
      });
    },
  }
};
</script>

<style>
.dialog-footer {
  text-align: center;
}
</style>
